package com.yx.xinruitu.lbxupdate.service;

import com.yx.xinruitu.entity.Staff;
import com.yx.xinruitu.lbxupdate.mapper.Wx_StaffMapper;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class Wx_StaffService {
    private final Wx_StaffMapper wxStaffMapper;

    public Wx_StaffService(Wx_StaffMapper wxStaffMapper) {
        this.wxStaffMapper = wxStaffMapper;
    }


    public Staff isCompletion(String openid) {
        if (wxStaffMapper.isCompletion(openid) == null) {
            Staff staff = new Staff();
            staff.setOpenId(openid);
            wxStaffMapper.insetStaffOnlyOpenId(staff);
        }
        return wxStaffMapper.isCompletion(openid);
    }


    public int updateStaff(Staff staff) {
        staff.setDeptId(wxStaffMapper.getCompanyIdByName(staff.getCompany()));
        return wxStaffMapper.updateStaff(staff);
    }

    public List<String> getCompany(){
        return wxStaffMapper.getCompany();
    }

}
